<template>
  <div id="views" @click="showBasePower = false">
    <div id="top">
      <p class="title">
        <img src="../../common/imgs/danwa.png" alt="图片" id="logo" class="middle">
        <span v-if="machine" class="middle name">{{machine.productName}}</span>
      </p>
    </div>
    <div id="content">
      <section id="sec1">
        <p>
          <span class="span1" v-if="machine">
            <span>{{machine.totalDeposit}}</span><span class="unit">{{machine.paymentCurrencyCode == "BCNY" ? 'OTC余额' : machine.paymentCurrencyCode}}</span>
          </span>
          <span class="disCoupons" v-if="machine && Number(machine.preferential) > 0">
              <img src="../../common/imgs/coupon_logo.png" alt="coupons" class="middle">
              <span class="middle">含抵扣 {{machine.preferential}} {{machine.paymentCurrencyCode}}</span>
          </span>
          <span class="drugStatus">
            <span v-if="machine" :class="machine.machineClass">{{machine.workText}}</span>
          </span>
        </p>
        <p>
          <span>订单份额 <span v-if="machine">{{machine.num}}份</span></span>
          <span>订单到手总算力 <span v-if="machine">{{handsPower}}</span></span>
        </p>
      </section>
      <section id="sec2">
        <p>
          <span>订单号</span>
          <span class="orderNumber">{{orderId}}</span>
        </p>
<!--        <p class="showthisText">-->
<!--          <span>历史产出</span>-->
<!--          <span >-->
<!--            <span class="historyProBhp" v-if="machine">{{machine.btcIncomeNum}} BTC</span>-->
<!--          </span>-->
<!--        </p>-->
        <p>
          <span>分币比例</span>
          <span class="digtime" style="color: #FA4C4C">
            <span v-if="machine">{{this.accMul(machine.distributionRate , 100)}}%</span>
          </span>
        </p>
        <p>
          <span>发币方式</span>
          <span class="digtime">日结，次日发放至账户</span>
        </p>
        <p>
          <span>开挖时间</span>
          <span class="BeginrunningDate">
            <span v-if="machine">{{machine.startTime}}</span>
          </span>
        </p>
        <p v-if="machine && machine.regularDateNum > 30">
          <span class="changeName">锁定时间</span>
          <span class="endDate">{{machine.endTime}}</span>
        </p>
        <p v-if="machine && machine.dragStatus !=1 && machine.dragStatus !=0">
          <span>退单时间</span>
          <span class="stopRentTime">{{machine.updateTime}}</span>
        </p>
        <p v-if="machine && machine.renewalTime">
          <span>续单时间</span>
          <span class="tranferTime">{{machine.renewalTime}}</span>
        </p>
        <p>
          <span>算力来源</span>
          <span class="calculateSource">
            <span v-if="machine">{{machine.powerNodeName}}</span>
          </span>
        </p>
      </section>
      <section id="sec3">
        <p>
          <span>单份到手BTC算力</span>
          <span>
            <span v-if="machine">{{machine.basePower}}T</span>
          </span>
        </p>
        <p class="hoverhand" @click.stop.prevent="togglerBaseWin">
          <span>单份基础BTC算力</span>
          <span>
             <span v-if="machine">{{machine.computingPower}}T</span>
          </span>
        </p>
        <p v-if="machine.bhpPower > 0">
          <span>单份BHP参配算力</span>
          <span>
            <span v-if="machine" class="middle">{{machine.bhpPower}}T</span>
          </span>
        </p>
      </section>
      <section id="sec4" class="rechargeDetail" v-if="machine.type == 11">
        <div>
          <p>合约包剩余天数</p>
          <p class="powerLeastDays">
            <span v-if="machine">{{machine.toEnd}}</span>天
          </p>
          <p class="seeRechargeDetail">
            <router-link :to="{path:'/no_electric_recharge_detail' , query:{order_id : orderId}}">充值明细>></router-link>
          </p>
        </div>
        <div>
          <p>电费包剩余</p>
          <p class="powerLeastDays2">
            <span v-if="machine">{{machine.eToEnd}}</span>天
          </p>
        </div>
        <div>
          <router-link :to="{path:'/no_electric_add_electric' , query :{ order_id : orderId, handsPower : handsPower, machine : JSON.stringify(machine)}}" class="toAdd" id="addElectric">
            去充值
          </router-link>
        </div>
      </section>
      <section id="sec44" class="incomenStatisc">
        <p class="topTitle">
          <span class="title">产出统计</span>
          <span class="isPro" v-if="machine.insuranceOrderId > 0 && machine.newInsuranceOrder && machine.newInsuranceOrder.settlement_state == 0">产出保障中</span>
          <span class="proOver" v-if="machine.insuranceOrderId > 0 && machine.newInsuranceOrder && machine.newInsuranceOrder.settlement_state == 1">保障已完成</span>
        </p>
        <div class="clm">
          <span>当前产出</span>
          <div class="ct">
            <span style="padding-bottom: 0.1rem">{{machine.btcIncomeNum}} BTC <span style="color: #999">≈{{machine.btcIncomeToCny}} CNY</span></span>
            <span v-if="Number(machine.bhpPower) > 0">{{machine.bhpIncomeNum}} BHP <span style="color: #999">≈{{machine.bhpIncomeToCny}} CNY</span></span>
          </div>
        </div>
        <div class="clm">
          <span>产币天数</span>
          <div class="ct">
            <span>{{machine.toNow}}天</span>
          </div>
        </div>
        <div class="clm">
          <span>当前产出率</span>
          <div class="ct">
            <span>{{machine.income_rate}}%</span>
          </div>
        </div>
<!--        <div class="btm">-->
<!--          2020-01-01产出率达到XX%，已转入产出共享阶段，分币比例调整为XX%-->
<!--        </div>-->
      </section>
      <section id="sec5" v-if="machine && machine.newInsuranceOrder">
        <router-link :to="{path:'/increment_detail' , query:{machine : JSON.stringify(machine)}}">
          <span>增值服务</span>
          <span>
            <img src="../../common/imgs/arrowright.png" alt="图片">
          </span>
        </router-link>
        <p>
          <span v-if="machine.insuranceContract">{{machine.insuranceContract.name}}</span>
          <span class="not_buy" v-if="!machine.insuranceContract">暂未购买增值服务</span>
          <span v-if="machine.insuranceContract">
            <span>{{machine.addServiceCreateTime}} - {{machine.addServiceEndTime}}</span>
          </span>
        </p>
      </section>
    </div>
    <transition name="fade">
      <div v-if="showBasePower">
        <div class="publicCover"></div>
        <div  class="basePowerWin">
          <div class="top">
            <p>奖励算力</p>
            <p>{{machine.addRewardPower}} T</p>
          </div>
          <div class="windowList">
            <p><span>浮动算力</span> <span class="floatpower">{{machine.floatPower}}T</span></p>
            <p><span>达标算力</span> <span class="pepower">{{machine.pePower}}T</span></p>
            <p><span>期货算力</span> <span class="hopepower">{{machine.futuresPower}}T</span></p>
            <p><span>定期算力</span> <span class="setdatepower">{{machine.regularPower}}T</span></p>
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>
<script>
  import { orderDetail } from '../../http/api';

  export default {
    name : 'not_return_power_detail',
    data(){
      return{
        introduce : '不可回购合约包详情',
        orderId : '',//订单id
        machine : '',//矿机信息
        handsPower : '',//到手总算力
        hisToryProduct : '',//历史产出
        showBasePower : false,//
      }
    },
    mounted() {
      let query = this.$route.query;
      this.orderId = query.orderId;
      this.loadMachineMes();
    },
    methods:{
      togglerBaseWin(){
        this.showBasePower = !this.showBasePower
      },
      loadMachineMes(){
        let thiz = this;
        orderDetail({orderId : thiz.orderId}).then(res => {
          if( res.code == 200){
            let data = res.data;
            let dragStatus = data.dragStatus;
            switch (dragStatus) {
              case 0:
                data.machineClass = 'waitDrug';
                break;
              case -1:
                data.machineClass = 'isStop';
                break;
              case 1:
                data.machineClass = 'isRun';
                break;
            }
            data.unitHandsPower = thiz.accAddMore(
              data.futuresPower,  data.regularPower,
              data.floatPower,  data.pePower
            );
            data.addRewardPower = thiz.accAddMore(
              data.futuresPower, data.regularPower,
              data.floatPower, data.pePower
            );
            if( data.insuranceContract ){
              data.addServiceCreateTime = data.newInsuranceOrder.create_time.replace(/-/g, "/").split(' ')[0];
              data.addServiceEndTime = data.newInsuranceOrder.settlement_time.replace(/-/g, "/").split(' ')[0];
            }
            this.handsPower = thiz.accMul(data.computingPower, data.num) + (data.currencyCode != "BTC" ? 'M' : 'T');
            thiz.machine = data;
          }
        })
      },
    }
  }
</script>
<style type="text/less" lang="less" scoped>
  #views{
    padding-bottom: 0.3rem;
  }
  #top{
    height: 2.34rem;background: url("../../common/imgs/machinedetail_bg.png") center center no-repeat;background-size: 100% 100%;
    .title{
      line-height: 0.4rem;padding-top: 0.48rem;padding-bottom: 0.28rem;padding-left: .3rem;
      #logo{
        width: 0.3rem;
      }
      .name{
        color: #301405;font-size: .32rem;padding-left: 0.1rem;font-family: 'PingFang-SC-Bold';
      }
    }
  }
  #content{
    margin-top: -1.2rem;padding: 0 0.3rem;
    >section{
      background: #fff;border-radius: 0.04rem;margin-top: 0.16rem;
    }
    >section:first-child{
      margin-top: 0;
    }
  }
  #sec1{
    padding: 0.34rem 0.32rem;padding-bottom: 0;
    p:first-child{
      overflow: hidden;
      >.span1{
        color: #B57B28;font-size: 0.48rem;position: relative;
        >.unit{
          font-size: 0.28rem;
        }
      }
      >.disCoupons{
        bottom: 0;color: #F78559;font-size: 0.22rem;
        img{
          width: 0.26rem;
        }
        >span{
          line-height: 0.26rem;
        }
      }
      >.drugStatus{
        float: right;
        >span{
          font-size: .22rem;line-height: .48rem;padding:0 0.3rem;height: 0.48rem;display: inline-block;border-radius: 0.04rem;
        }
        >.isRun{
          color: #42AA79;background: rgba(66, 170, 121, 0.18);
        }
        >.waitDrug{
          color:#43b1f9;background: rgba(67, 177, 249, 0.12);
        }
        >.isStop{
          color: #ED5A5A;background: rgba(237, 90, 90, 0.11);
        }
      }
    }
    p:last-child{
      font-size: 0.24rem;overflow: hidden;padding-top: 0.45rem;padding-bottom: 0.32rem;
      >span:first-child{
        float: left;
      }
      >span:first-child{
        float: right;
      }

    }
  }
  #sec2{
    padding: 0.2rem 0.3rem;padding-bottom: 0.3rem;
    >p{
      overflow: hidden;font-size: 0.26rem;padding-top: 0.24rem;
      >span:first-child{
        color: #999999;float: left;
      }
      >span:last-child{
        color: #262626;float: right;
      }
    }
  }
  #sec3{
    padding: 0 0.26rem;padding-bottom: 0.29rem;
    >p{
      padding-top: 0.29rem;overflow: hidden;
      >span{
        position: relative;color: #999999;font-size: 0.26rem;
      }
      >span:first-child{
        float: left;
      }
      >span:last-child{
        float: right;color: #262626;
      }
    }
    >p:last-child{
      border-bottom: none;
    }
  }
  #sec4 {
    color: #999999;
    font-size: 0.24rem;
    overflow: hidden;
    background: #fff;
    width: 100%;
    margin-top: 0.2rem;
    border-radius: 0.1rem;
    padding: 0.33rem 0.28rem;
    box-sizing: border-box;
  }
  #sec4>div {
    float: left;
  }
  #sec4>div:first-child {
    width: 40%;
  }
  #sec4>div:nth-child(2) {
    width: 35%;
  }
  #sec4>div>p:nth-child(2) {
    padding: 0.25rem 0;
    color: #262626;
  }
  #sec4>div:nth-child(2)>p:nth-child(2) {
    color: #F15342;
  }
  #sec4 .toAdd {
    background: #FFD203;
    padding: 0.19rem 0.34rem;
    border-radius: 0.04rem;
    color: #262626;
    display: inline-block;
    line-height: 100%;
  }
  #sec4>div:last-child {
    float: right;
  }
  #sec4 .seeRechargeDetail a{
    text-decoration: underline;color: #999999;
  }
  #sec5{
    padding: 0 0.26rem;
    a:first-child{
      color: #262626;font-size: 0.28rem;overflow: hidden;border-bottom: 0.015rem solid #F5F6F8;height: 0.9rem;display: block;
      >span{
        line-height: 0.9rem;
      }
      >span:first-child{
        float: left;
      }
      >span:last-child{
        float: right;
        img{
          width: 0.12rem;
        }
      }
    }
    p:last-child{
      height: 0.9rem;color: #898989;font-size: 0.24rem;
      >span{
        line-height: 0.9rem;
      }
      >span:first-child{
        float: left;
      }
      >span:last-child{
        float: right;padding-right: 0.3rem;
      }
      >.not_buy{
        font-size: 0.26rem;display: block;text-align: center;width: 100%;padding-right: 0!important;
      }
    }
  }
  .incomenStatisc{
    padding: 0 0.28rem;background: #fff;margin-top: 0.2rem;border-radius: 0.04rem;width: 100%;box-sizing: border-box;padding-bottom: 0.3rem;padding-top: 0.1rem;
  }
  .incomenStatisc .topTitle{
    height: 0.8rem;line-height: 0.8rem;
  }
  .incomenStatisc .isPro,.incomenStatisc .proOver{
    line-height: 0.34rem;height: 0.34rem;font-size: 0.2rem;padding: 0.05rem 0.1rem;
  }
  .incomenStatisc .isPro{
    color: #F4930A;background: rgba(255, 163, 3, 0.12);
  }
  .incomenStatisc .proOver{
    color: #22C2B5;background: rgba(34, 194, 181, 0.13);
  }
  .incomenStatisc .topTitle .title{
    color: #262626;font-size: 0.28rem;
  }
  .incomenStatisc .clm{
    overflow:hidden;padding-bottom: 0.2rem;
  }
  .incomenStatisc .clm>span{
    float: left;
  }
  .incomenStatisc .clm>span:first-child{
    color: #999999;font-size: 0.24rem;width: 1.6rem;display: inline-block;
  }
  .incomenStatisc .clm>.ct{
    padding-left: 0rem;display: inline-block;float: left;width: calc( 100% - 1.6rem);box-sizing: border-box;font-size: 0.24rem;
  }
  .incomenStatisc .clm>.ct>span{
    display: inline-block;width: 100%;
  }
  .incomenStatisc .btm{
    line-height: 130%;font-size: 0.22rem;color: #898989;background: #FEFAEC;padding: 0.19rem 0.15rem;
  }
  .incomenStatisc .clm:last-child{
    padding-bottom: 0;
  }
  .basePowerWin{
    position: fixed;width: 4rem;background: #fff;z-index: 11;top: 50%;-webkit-transform: translateY(-50%);transform: translateY(-50%);
    left: 50%;margin-left: -2.5rem;border-radius: 0.15rem; overflow: hidden;
    >.top{
      width: 100%;background: #ffd203;text-align: center;
      >p:first-child{
        padding: 0.2rem 0;padding-bottom: 0.1rem;
      }
      >p:last-child{
        padding-bottom: 0.2rem;
      }
    }
    >.windowList{
      padding-bottom: 0.3rem;padding-top: 0.15rem;
      >p{
        overflow: hidden;padding: 0.2rem 0.25rem 0 0.25rem;
        >span:first-child{
          float: left;
        }
        >span:last-child{
          float: right;
        }
      }
    }
  }
  .fade-enter,.fade-leave-to{
    opacity: 0;
  }
  .fade-enter-to,.fade-leave{
    opacity: 1;
  }
  .fade-enter-active,.fade-leave-active{
    transition: all 0.2s;
  }
</style>
